home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-21 | 3.0 KB | 118 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LSingleLineCaption.cp ©1993-1995 Metrowerks Inc. All rights reserved.
- // ©1996 Chris K. Thomas.
- // ===========================================================================
- //
- // LCaption optimized for a single line of text.
- //
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- #include "LSingleLineCaption.h"
- #include <LStream.h>
- #include <UDrawingUtils.h>
- #include <UDrawingState.h>
- #include <UTextTraits.h>
-
- #ifndef __TEXTUTILS__
- #include <TextUtils.h>
- #endif
-
-
- // ---------------------------------------------------------------------------
- // • CreateCaptionStream
- // ---------------------------------------------------------------------------
- // Create a new Caption object from the data in a Stream
-
- LSingleLineCaption*
- LSingleLineCaption::CreateCaptionStream(
- LStream *inStream)
- {
- return (new LSingleLineCaption(inStream));
- }
-
-
- // ---------------------------------------------------------------------------
- // • LSingleLineCaption
- // ---------------------------------------------------------------------------
- // Default Constructor
-
- LSingleLineCaption::LSingleLineCaption()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LSingleLineCaption(const LSingleLineCaption&)
- // ---------------------------------------------------------------------------
- // Copy Constructor
-
- LSingleLineCaption::LSingleLineCaption(
- const LSingleLineCaption &inOriginal)
- : LCaption(inOriginal)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • LSingleLineCaption(LStream*)
- // ---------------------------------------------------------------------------
- // Construct from data in a Stream
-
- LSingleLineCaption::LSingleLineCaption(
- LStream *inStream)
- : LCaption(inStream)
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~LSingleLineCaption
- // ---------------------------------------------------------------------------
- // Destructor
-
- LSingleLineCaption::~LSingleLineCaption()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • DrawSelf
- // ---------------------------------------------------------------------------
- // Draw the Caption -- optimized for a single line with clear ’til
- // end-of-line behavior - without flashing
-
- void
- LSingleLineCaption::DrawSelf()
- {
- Rect frame;
- CalcLocalFrameRect(frame);
-
- StClipRgnState clipto(frame);
-
- Int16 just = UTextTraits::SetPortTextTraits(mTxtrID);
-
- RGBColor textColor;
- ::GetForeColor(&textColor);
-
- ApplyForeAndBackColors();
- ::RGBForeColor(&textColor);
-
- MoveTo(frame.left, frame.bottom - 3); // ••• fixme -- Use FontInfo
- DrawString(mText);
-
- //
- // QuickDraw has now set the pen horizontal coord
- // to the end of the drawn text
- //
- PenState ourPen;
- GetPenState(&ourPen);
-
- frame.left = ourPen.pnLoc.h;
- EraseRect(&frame);
-
- // UTextDrawing::DrawWithJustification((Ptr)&mText[1], mText[0], frame, just);
- }
-